<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="../../Themes/default/easyui.css">
    <link rel="stylesheet" type="text/css" href="../../Themes/icon.css">
    <link rel="stylesheet" type="text/css" href="common.css">
    <link rel="stylesheet" type="text/css" href="../../CSS/demo.css">
    <link rel="stylesheet" type="text/css" href="../../CSS/common.css">
</head>

<body style="padding: 0px;">

<div id="header_toolbar" class="btn-group-background"></div>
<div id="form_header">
    <form id="ff">
        <table cellpadding="5" class="displaytable" style="text-align: left;width: 80%;margin: 0 auto;">
            <tr>
                <td width="20%">
                    <h class="star">*</h>
                    配送单位
                </td>
                <td width="30%">
                    <input class="easyui-combobox" style="width: 100%" type="text" name="CUSTOMER_NAME"
                           id="input_CUSTOMER_NAME" data-options="disabled:true"/>
                </td>
                <td width="20%">
                    <h class="star">*</h>
                    用户组
                </td>
                <td width="30%">
                    <input class="easyui-combobox" style="width: 100%;" type="text" name="CUSTOMER_TYPE"
                           id="input_CUSTOMER_TYPE" data-options="disabled:true">
                </td>
            </tr>
            <tr>
                <td>
                    <h class="star">*</h>
                    订单编号
                </td>
                <td>
                    <input class="easyui-textbox" style="width: 100%;" type="text" name="ORDER_NO" id="input_ORDER_NO"
                           data-options="prompt:'由系统自动生成，不需填写',disabled:true">
                </td>
                <td>
                    <h class="star">*</h>
                    配送时间
                </td>
                <td>
                    <input class="easyui-datebox" style="width:100%;" type="text" name="DISTRIBUTION_DATE"
                           id="input_DISTRIBUTION_DATE" data-options="prompt:'由系统自动生成，不需填写',disabled:true"/>
                </td>
            </tr>
            <tr id="nodisplay" style="display: none">
                <td>
                    <h class="star">*</h>
                    用户组ID
                </td>
                <td>
                    <input class="easyui-textbox" style="width:100%;" type="text" name="CUSTOMERTYPE_ID"
                           id="input_CUSTOMERTYPE_ID" data-options="prompt:'由系统自动生成，不需填写',disabled:true"/>
                </td>
                <td width="20%">
                    <h class="star">*</h>
                    配送单位编号
                </td>
                <td width="30%">
                    <input class="easyui-textbox" style="width: 100%;" type="text" name="CUSTOMER_ID"
                           id="input_CUSTOMER_ID" data-options="required:true,disabled:true"/>
                </td>
            </tr>
            <tr>
                <td>
                    <h class="star">*</h>
                    订单状态
                </td>
                <td>
                    <input class="easyui-textbox" style="width:100%;" type="text" name="STATE" id="input_STATE"
                           data-options="prompt:'由系统自动生成，不需填写',disabled:true"/>
                </td>
            </tr>
        </table>
    </form>
</div>
<div id="detail">
    <div id="detail_toolbar">
        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true"
           onclick="appendRow()">新增</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true"
           onclick="deleteRow()">删除</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-cancel',plain:true"
           onclick="cancelEdit()">取消</a>
    </div>
    <table id="edg">

    </table>
</div>
<div id="footer"></div>
<script type="text/javascript" src="../../JS/jquery.min.js"></script>
<script type="text/javascript" src="../../JS/jquery.easyui.min.js"></script>
<script type="text/javascript" src="./common.js"></script>
<script type="text/javascript" src="../../JS/common.js"></script>
<script type="text/javascript" src="../../JS/jquery.edatagrid.js"></script>
<script type="text/javascript" src="GenerateTemplate.js"></script>
<script type="text/javascript" src="GenerateToolBar.js"></script>
<script type="text/javascript" src="./SellOrderAdd.js"></script>
<script type="text/javascript">
    /*表单按钮*/
    var generateToolBar = new GenerateToolBar();
    var content = generateToolBar.getToolBarContent(['FRONT', 'NEXT', 'SAVE', 'DELETE', 'VERIFY', 'UNVERIFY', 'UNVERIFY', 'PRINT']);
    $('#header_toolbar').append(content);

    /*表格初始化*/
    $("#edg").edatagrid({
        height: 310,
        toolbar: '#detail_toolbar',
        collapsible: 'true',
        singleSelect: 'true',
        rownumbers: 'true',
        fitColumns: 'true',
        showFooter: 'true',
        onEndEdit: onEndEdit,
        onBeginEdit: onBeginEdit,
        autoSave: 'true',
        columns: [
            [{
                field: 'INTERNAL_NAME',
                title: '*内部商品名',
                width: '16%',
                align: 'center',
                editor: {
                    type: 'combobox',
                    options: {
                        valueField: 'INTERNAL_NAME',
                        textField: 'INTERNAL_NAME',
                        panelWidth: 200,
                        panelHeight: 'auto',
                        mode: 'remote',
                        method: 'get',
                        onChange: function (newValue, oldValue) {

                        },
                        onSelect: function (record) {

                        }
                    }
                }
            }, {
                field: 'INTERNAL_TYPE',
                title: '*内部商品类型',
                width: '16%',
                align: 'center',
                editor: {
                    type: 'textbox',
                    options: {
                        valueField: "INTERNAL_TYPE",
                        textField: "INTERNAL_TYPE",
                        editable: true,
                        required: true
                    }
                }
            }, {
                field: 'UNIT_NAME',
                title: '*单位',
                width: '16%',
                align: 'center',
                editor: {
                    type: 'textbox',
                    options: {
                        valueField: "UNIT_NAME",
                        textField: "UNIT_NAME"
                    }
                }
            }, {
                field: 'AMOUNT',
                title: '*数量',
                width: '16%',
                align: 'center',
                editor: {
                    type: 'numberbox',
                    options: {
                        required: true,
                        precision: 2,
                        groupSeparator: ',',
                        decimalSeparator: '.'
                    }
                }
            }, {
                field: 'UNIT_PRICE',
                title: '*单价',
                width: '16%',
                align: 'center',
                editor: {
                    type: 'numberbox',
                    options: {
                        required: true,
                        precision: 2, //保留两位
                        groupSeparator: ',', //每组用','隔开
                        decimalSeparator: '.',
                        prefix: '￥' //在数据前面加￥符号
                    }
                },
                formatter: function (value, row, index) {
                    if (value) {
                        return "￥" + value + "元";
                    }
                }
            }, {
                field: 'SUM',
                title: '*总价',
                width: '16%',
                align: 'center',
                formatter: function (value, row, index) {
                    if (value) {
                        return "￥" + value + "元";
                    }
                }
            }]
        ]
    });


    /**加载数据**/
    var sellOrderAdd = new SellOrderAdd();
    sellOrderAdd.basicUrl = 'logistics/salesorder';
    sellOrderAdd.init();

    /*表单事件*/
    function front(){
        sellOrderAdd.frontPage();
    }
    function next() {
        sellOrderAdd.nextPage();
    }
    function save() {
        
    }
    function remove() {
        
    }
    function verify() {
        
    }
    function search() {
        
    }
    function print() {
        
    }

    /*表格事件*/
    function onEndEdit(index, row, changes) {
        sellOrderAdd.currentIndex = -1;
    }

    function onBeginEdit(index, row) {
        sellOrderAdd.currentIndex = index;
    }


    /**表格明细按钮**/

    function appendRow() {
        $('#edg').edatagrid('addRow');
    }

    function deleteRow() {
        $('#edg').edatagrid('destroyRow');
    }

    function cancelEdit() {
        $('#edg').edatagrid('cancelRow');
        sellOrderAdd.currentIndex = -1;
    }
</script>

</body>

</html>
